package com.cts.controller.admin;

import com.cts.annotation.OperationLogger;
import com.cts.entity.SiteSetting;
import com.cts.model.dto.SiteSettingDTO;
import com.cts.model.vo.Result;
import com.cts.service.SiteSettingService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @projectName: CBlog
 * @package: com.cts.controller.admin
 * @className: SiteSettingAdminController
 * @author: chentongsheng
 * @description: TODO
 * @date: 2023/2/25 00:45
 * @version: 1.0
 */
@RestController
@RequestMapping("/admin")
public class SiteSettingAdminController {

    @Autowired
    SiteSettingService siteSettingService;

    @OperationLogger("站点设置查询")
    @ApiOperation("站点设置查询")
    @RequestMapping("/siteSetting")
    public Result getSiteSetting(@RequestParam("type") Integer type){
        List<SiteSetting> list = siteSettingService.getSiteSetting(type);
        return Result.ok("请求成功", list);
    }

    @OperationLogger("站点设置保存")
    @ApiOperation("站点设置保存")
    @PostMapping("/siteSetting")
    public Result saveSiteSetting(@RequestBody List<SiteSetting> siteSetting){
        Boolean save = siteSettingService.updateBatchById(siteSetting);
        return Result.ok("保存成功");
    }

}
